<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象显示</title>
</head>
<body>
<!--以JSON格式显示属性-->
<p id="demo"></p>
<p id="demo1"></p>
<script>
  const person = {
    name: "Bill",
    age: function () {
      return 19;
    },
    city: "BeiJin",
    //将日期转换为字符串
    today: new Date()
  };
person.age = person.age.toString();
  document.getElementById("demo").innerHTML =
          JSON.stringify(person);

  //对数组进行字符串化
  const arr = ["Bill", "Steve", "Elon", "David"];
  document.getElementById("demo1").innerHTML = JSON.stringify(arr);
</script>
</body>
</html>